/*
 * Copyright (c) 2024 Black Sesame Technologies
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <gtest/gtest.h>
#include "dal_cyclonedds/converter/InstanceHandleConverter.hpp"

TEST(test_convert_instance_handle_from_fastdds_to_dal, instance_handle_convert_default)
{
    dal_instance_handle_t d_ins;
    dds_instance_handle_t c_ins;
    d_ins.segment_0_ = 0x00112233;
    d_ins.segment_1_ = 0x44556677;
    d_ins.segment_2_ = 0;
    d_ins.segment_3_ = 0;
    dal_ret_t ret = InstanceHandleConverter::GetInstance()->ConvertInstanceHandleFromDalToCyclonedds(
        &d_ins, &c_ins);
    EXPECT_EQ(ret, DAL_RETCODE_OK);
    
    EXPECT_EQ(c_ins, 0x4455667700112233);
}

TEST(test_convert_instance_handle_from_dal_to_fastdds, instance_handle_convert_default)
{
    dal_instance_handle_t d_ins;
    dds_instance_handle_t c_ins;
    c_ins = 0x4455667700112233;

    dal_ret_t ret = InstanceHandleConverter::GetInstance()->ConvertInstanceHandleFromCycloneddsToDal(
        &c_ins, &d_ins);
    EXPECT_EQ(ret, DAL_RETCODE_OK);
    EXPECT_EQ(d_ins.segment_0_, 0x00112233);
    EXPECT_EQ(d_ins.segment_1_, 0x44556677);
    EXPECT_EQ(d_ins.segment_2_, 0);
    EXPECT_EQ(d_ins.segment_3_, 0);
}